package com.onstar.cn.api;

import com.onstar.cn.api.framework.ClazzInjectUtils;
import com.onstar.cn.api.framework.annotation.Path;
import com.onstar.cn.api.framework.annotation.PathParams;
import com.onstar.cn.api.framework.annotation.RequestMapping;
import com.onstar.cn.framework.network.entity.RequestEntity;
import com.onstar.cn.framework.utils.GsonHelper;
import com.onstar.cn.smart.request.LoginAuthInfo;

@Path("/msp/api/v3/device")
public class AuthQRCodeService {

    private String serverURL;

    /**
     * @Description: TODO
     * @author 6335yz
     * @date 2015年8月20日 下午3:36:47
     */
    public AuthQRCodeService(String serverURL) {
        this.serverURL = serverURL;
    }


    @RequestMapping("/qrcode/scan/{qrcode}")
    public RequestEntity authQRCode(RequestEntity requestEntity, LoginAuthInfo entity,@PathParams(value = "qrcode") String qrCode) {
        if (requestEntity == null) {
            requestEntity = new RequestEntity();
        }
        String url = ClazzInjectUtils.injectUrl(getClass(), "authQRCode", requestEntity, entity,qrCode);
        requestEntity.setUrl(serverURL + url);
        if (entity != null) {
            requestEntity.setBody(GsonHelper.toJson(entity));
        }
        return requestEntity;
    }


}
